﻿
Public Class frmLogin
    Private ReadOnly key() As Byte = _
{1, 2, 3, 56, 5, 6, 36, 8, 9, 10, 11, 12, 63, 14, _
15, 49, 44, 65, 19, 84, 21, 22, 28, 24}
    Private ReadOnly iv() As Byte = {1, 2, 45, 3, 22, 7, 84, 1}

    ' instantiate the class with the arrays
    Private des As New TripleDES(key, iv)

    Public UserLevel As Integer = -2

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        Try
            UserLevel = Form1.oWS.CheckUser(des.Encrypt(UsernameTextBox.Text), des.Encrypt(PasswordTextBox.Text))

            If UserLevel > -2 Then
                Form1.UserLevel = UserLevel
                Form1.UserName = UsernameTextBox.Text
                Form1.Password = des.Encrypt(PasswordTextBox.Text)
                DialogResult = Windows.Forms.DialogResult.OK
            Else
                DialogResult = Windows.Forms.DialogResult.No
            End If
            Me.Close()
        Catch ex As Exception
            MsgBox(ex.ToString, MsgBoxStyle.Critical, "Error")
        End Try

    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        DialogResult = Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
